//
//  ViewController.m
//  Quartz2DDemo
//
//  Created by abc on 2019/4/26.
//  Copyright © 2019年 汪保锋. All rights reserved.
//

#import "ViewController.h"
#import "BaseViewController.h"
#import "StationeryViewController.h"

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;
@end


@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.navigationItem.title = @"Quartz2D学习";
    
    [self.view addSubview:self.tableView];
}


-(UITableView *)tableView {
    
    if (!_tableView) {
        
        _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsVerticalScrollIndicator = NO;
        //        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.estimatedRowHeight = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
        _tableView.estimatedSectionFooterHeight = 0;
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
        _tableView.tableFooterView = [UIView new];
        _tableView.tableHeaderView = [UIView new];

    }
    return _tableView;
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 50;
    
}

-(CGFloat )tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    return 0.01;
    
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
    return [UIView new];
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    return 40;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    UIView *hesadView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 40)];
    UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 200, 20)];
    [hesadView addSubview:titlelabel];
    titlelabel.text = @"基础入门";
    return hesadView;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.row == 0) {
      cell.textLabel.text = @"画直线/扇形/椭圆";
    }else if (indexPath.row == 1) {
        cell.textLabel.text = @"信纸条纹效果";
    }
    
    return cell;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            
            BaseViewController *baseVc = [[BaseViewController alloc]init];
            [self.navigationController pushViewController:baseVc animated:YES];
        }
        else if (indexPath.row == 1) {
            
            StationeryViewController *vc = [[StationeryViewController alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
    }
}






    









@end
